x
static forEachTest(namespace: any, callback: (name: string, _this_: any, test: () => void) => void) { } private _updateTimes() { if (this.running().length + this.notStarted().length === 0) { clearInterval(this._updateTimesInterval); this._updateTimesInterval = 0; return; } var now = Date.now(); (this.running(), t => t.updateTimes(now)); } private _continueStarting() { var now = Date.now(); (this.running(), t => { t.updateTimes(now); }); var nextRest = Date.now() + this.workQuantum; while (true) { if (!this.notStarted().length) return; this._startOne(); if (!this.notStarted().length) return; if (Date.now() >= nextRest) { this._queueWorkItem(this._continueStartingClosure); return; } } } private _startOne() { var nextTest = this.notStarted.shift(); this.running.push(nextTest); nextTest.start(() => { this.running.remove(nextTest); var newState = nextTest.state(); var targetCollection = newState === TestCase.State.Succeeded ? this.succeeded : newState === TestCase.State.Failed ? this.failed : null; if (targetCollection) { var targetCollectionArray = targetCollection(); // iterate backwards, as the tests are likely to complete in the order they started for (var i = targetCollectionArray.length - 1; i >= 0; i--) { var t = targetCollectionArray[i]; if (nextTest.name > t.name) { targetCollection.splice(i + 1, 0, nextTest); return; } } targetCollection.unshift(nextTest); } }); }